const db = require("../models");
const News = db.news;

exports.getNews = (req, res) => {
    News.findAll({ attributes:['url'] })
        .then((data) => {
            res.setHeader("Access-Control-Allow-Origin", '*')
            res.send(data);
        })
        .catch((err) => {
            res.status(500).send({
                message: err.message || "获取资讯失败",
            });
        });
}

exports.getNewsNum = (req, res) => {
    let pages = [];
    News.findAll({ attributes: ['url'] })
        .then((data) => {
            res.setHeader("Access-Control-Allow-Origin", '*')
            pages = data
            res.send(pages.length);
        });
}